package com.dao;

import com.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    @Select("select * from smbms_user")
    public List<User> getAll();

    @Insert("INSERT INTO smbms_user (userName, userPassword) " +
            "VALUES (#{userName}, #{userPassword})")
    public int addNewUser(User user);

    @Select("select * from smbms_user where userName=#{username} and userPassword=#{password}")
            public User login(@Param("username") String userName,
            @Param("password") String Password);

    @Select("select * from smbms_user")
    @Results(@Result(column = "userRole", property = "role", one = @One(select ="com.mapper.RoleMapper.getRoleById")))
    public List<User> getAllUser();

    @Select("select * from smbms_user where userRole")
    public User getUserListByRole();

    @Select("select * from smbms_user")
    @Results(@Result(column = "userRole", property = "role", one = @One(select =
            "com.mapper.RoleMapper.getRoleById")))
    public List<User> getAllwithRole();

    @Select("SELECT * FROM smbms_user WHERE userRole = #{id}")
    public List<User> getUsersByRoleId(Integer id);

}
